﻿#ifndef INJECTORWINDOW_H
#define INJECTORWINDOW_H


#include "../model/injectortablemodel.h"
#include "../threads/sqlthread.h"
#include "../threads/serialthread.h"
#include "injectorsettingwidget.h"

class InjectorWindow : public QWidget
{
    Q_OBJECT
public:
    InjectorWindow();
    ~InjectorWindow();

    InjectorTableModel* m_modelInjectorTable;
    QTableView* injTableView;
    void setup_tableview();
    //injector setting widget
    InjectorSettingWidget* injectorSettingWidget;

public slots:
    //sql
    void slt_addgetId(uint);
    void confirmSetting();
    //serial
    void slt_serialData(const SerialPack&);

signals:
    void sig_add(const InjectorData& data);
    void sig_delete(uint id);
    void sig_updateSetting(const InjectorSetting& setting, uint id);
    void sig_updateInfo(const QString& name, const QString& pos, uint id);
    void sig_updateStatus(const SerialPack& pack, uint id);

    void sig_respond(const QByteArray& data);

private:
    void setup_ui();
    QToolButton* addButton;
    //inj table
    QLayout* setup_injTable();
    QMenu* menu;
    QAction *deleteAction;

    void setup_model();
    void setup_ui_slots();

    //threads
    SqlThread* sqlThread;
    SerialThread* serialThread;

private slots:
    void slt_selected(const QModelIndex &index);
    void slt_addDialog();
    void slt_showMenu(const QPoint&);
    void slt_delete();
};

#endif // INJECTORWINDOW_H
